package com.dog.basics.api.controller.common;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.common.ArticleCommentAddDto;
import com.dog.basics.bean.dto.admin.common.ArticleCommentFormDto;
import com.dog.basics.bean.vo.admin.common.PcArticleCommentVo;
import com.dog.basics.bean.vo.api.common.ArticleCommentVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.constant.SwaggerConstants;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.security.annotation.Inner;
import com.dog.basics.service.common.IDogComArticleCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;

/**
 * <p>
 * CMS评论表 前端控制器
 * </p>
 *
 * @author guonh
 * @since 2020-05-23
 */
@RestController
@RequestMapping("/api/article/comment")
@Api(value = "CMS文章模块", tags = SwaggerConstants.API_ALL)
@AllArgsConstructor
@ApiIgnore
public class DogComArticleCommentController {

    private final IDogComArticleCommentService dogComArticleCommentService;
    /**
     * @Description: 增加cms文章评论
     * @Param:
     * @return: Boolean
     * @Author: zhangrm
     * @Date: 2020/05/22  0027
     */
    @ApiOperation(value = "增加cms文章评论", notes = "增加cms文章评论", tags = SwaggerConstants.API_TZWZ)
    @PostMapping("/save")
    public R<Boolean> save(@Valid @RequestBody ArticleCommentAddDto obj) {
        return R.ok(dogComArticleCommentService.saveObjApp(obj));
    }

    /**
     * @Description: 分页cms文章评论列表
     * @Param: status
     * @return: IPage<PcArticleCommentVo>
     * @Author: zhangmr
     * @Date:
     */
    @Inner
    @ApiOperation(value = "分页cms文章评论列表", notes = "分页cms文章评论列表", tags = SwaggerConstants.API_TZWZ)
    @GetMapping("/page")
    public R<IPage<ArticleCommentVo>> page(PageParam page, ArticleCommentFormDto ArticleCommentFormDto) {
        IPage<ArticleCommentVo> list = dogComArticleCommentService.getApiPageList(page, ArticleCommentFormDto);
        return R.ok(list);
    }


    /**
     * @Description: 增加cms文章评论点赞数量
     * @Param:
     * @return: Boolean
     * @Author: zhangrm
     * @Date: 2020/05/22  0027
     */
    @ApiOperation(value = "增加cms文章评论点赞数量", notes = "增加cms文章评论点赞数量", tags = SwaggerConstants.API_TZWZ)
    @ApiImplicitParams({
            @ApiImplicitParam(name ="id"  , value ="文章评论id",dataType = "Long",required = true ),
    })
    @PutMapping("/addedit")
    public R<Boolean> addedit( Long id) {
        return R.ok(dogComArticleCommentService.addedit(id));
    }

}
